package com.gz3;

import java.io.*;

public class Test_3 {
    public static void main(String[] args) {
        String srcpath = "E:\\Java\\java_code\\test\\picture(2).gif";
        String despath = "E:\\Java\\java_code\\test\\bufferedlianxi.gif";

        BufferedInputStream bufferedInputStream = null;
        BufferedOutputStream bufferedOutputStream = null;

        try {
            //用于二进制文件如视频、图片
            //bufferedreader用于字符文件
            bufferedInputStream = new BufferedInputStream(new FileInputStream(srcpath));
            bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(despath));
            int readlength = 0;
            byte[] buffer = new byte[1024];
            while ((readlength = bufferedInputStream.read(buffer)) != -1) {
                bufferedOutputStream.write(buffer, 0, readlength);
            }
            System.out.println("拷贝成功");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (bufferedInputStream != null) {
                    bufferedOutputStream.close();
                }
                if (bufferedOutputStream != null) {
                    bufferedOutputStream.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
